﻿package src.com.rageSteroid{
	
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.events.Event;
	
	public class Hero extends Sprite{
		
		public function Hero(){
			this.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
		}
		private function onAddedToStage(event:Event):void{
			this.removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
			
			this.graphics.beginFill(0x233589,0.8);
			this.graphics.lineStyle(2,0x055066);
			this.graphics.moveTo(-15,15);
			this.graphics.lineTo(0,-15);
			this.graphics.lineTo(15,15);
			this.graphics.lineTo(0,5);
			this.graphics.lineTo(-15,15);
			this.graphics.endFill();
			stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMouve);
		}
		
		private function onMouseMouve(event:MouseEvent):void{
			 this.rotation = (180*Math.atan2(stage.mouseY-this.y,stage.mouseX-this.x))/Math.PI + 90;
		}
	}	
}